import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import viteCompression from 'vite-plugin-compression';
const path = require('path')

// https://cn.vitejs.dev/config/
export default defineConfig({
	base: "/chain_web/",
	resolve: {
		alias: {
			"@": path.resolve(__dirname, "./src"),
			"@components": path.resolve(__dirname, "./src/components"),
			"@style": path.resolve(__dirname, "./src/style"),
			"@hooknet": path.resolve(__dirname, "./src/hook"),
			"@type": path.resolve(__dirname, "./src/types")
		},
	},
	css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@import "@style/common.scss";`
      }
    }
  },
	build: {
		minify: 'terser',
    terserOptions: {
      compress: {

        // 生产环境 去除 console, debugger
        drop_console: true,
        drop_debugger: true,
      }
    },
	},
	plugins: [vue(), viteCompression()],
	server: {
		port: 3000,
		// 是否自动在浏览器打开
		open: true,
		// 是否开启 https
		https: false,
		proxy: {
			"/sys": {
			  //local 本地测试联调
				target: "http://192.168.1.5:8887/",
				// target: "http://192.168.0.110:8887/",
				// target: "http://jxcloudlight.com/chain/",
				// target: "http://180.184.96.73/chain/",
				// target: "http://jxcloudlight.com/chain_test",
				// target: "http://2j330023k0.iask.in/",
				// target: "http://127.0.0.1:8887/",
				changeOrigin: true,
				rewrite: (pathStr) => pathStr.replace("/sys", "/"),
			},
			"/resources": {
				// target: "http://192.168.3.96:8887/",
				// target: "http://jxcloudlight.com/chain/",
				target: "http://180.184.96.73/chain/",
				// target: "http://jxcloudlight.com/chain_test",
				// target: "http://2j330023k0.iask.in/",
				changeOrigin: true,
				rewrite: (pathStr) => pathStr.replace("/resources", "/"),
			},
		},
	},
});
